package com.wyl.mybatis.mapper;

import com.wyl.mybatis.entity.FullCity;
import com.wyl.mybatis.page.Page;
import com.wyl.mybatis.req.FullCityReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @Description 省市区-字典
* @Author wuyilong
* @Date 2024-02-26
*/
@Mapper
public interface FullCityMapper {

    /**
     * 根据名称查询
     * @param name
     * @return
     */
    FullCity selectByName(@Param("name") String name);

    /**
     * 根据名称和code查询
     * @param name
     * @param code
     * @return
     */
    @Select(value = "select * from d_full_city where name = #{name} and code = #{code}")
    FullCity selectByNameAndCode(@Param("name") String name,@Param("code") String code);

    /**
     * 查询省市区
     * @param fullCityReq
     * @return
     */
    @Select(value = "select * from d_full_city where name = #{fullCityReq.name}")
    FullCity selectFullCity(@Param("fullCityReq") FullCityReq fullCityReq);

    /**
     * 省市区模糊查询
     * @param name
     * @return
     */
    @Select(value = "select * from d_full_city where name regexp #{name}")
    List<FullCity> selectFullCityLikeName(@Param("name")  String name);

    /**
     * 分页
     * @param page
     * @return
     */
    @Select("select * from d_full_city")
    List<FullCity> selectFullCityPage(@Param("page") Page page);

    /**
     * 统计表的数量
     * @param table
     * @return
     */
    @Select("select count(*) count from #{table}")
    Integer countTable(@Param("table") String table);
}
